#@adminLayout() #define main()

<link href="#(ctx)/static/ajax/libs/jquery-layout/jquery.layout-latest.css" rel="stylesheet"/>
<script src="#(ctx)/static/ajax/libs/jquery-layout/jquery.layout-latest.js"></script>

<link href="#(ctx)/static/ztree/css/metroStyle/metroStyle.css" rel="stylesheet"/>
<script src="#(ctx)/static/ztree/js/jquery.ztree.all-3.5.js"></script>

<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="user-form">
					<div class="select-list">
						<ul>
							
							<li>
							 工作类型	：<input type="text" name="w_type" style="width:180px"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
	        	<a class="btn btn-success " onclick="doAdd()" >
	                <i class="fa fa-plus"></i> 新增
	            </a>
            	<a class="btn btn-primary single disabled" onclick="doEdit()">
	                <i class="fa fa-edit"></i> 修改
	            </a>
	            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" > 
	                <i class="fa fa-remove"></i> 删除
	            </a>
	        </div>
	        
	        <div class="col-sm-12 select-table table-bordered">
			    <table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
	

<div class="modal fade" id="add_modal">
	  <div class="modal-dialog">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
	        <h4 class="modal-title">编辑</h4>
	      </div>
	      <div class="modal-body">
	        	<form id="form-config-add" method="post"  class="form-horizontal m" >
					<input id="id" name="id" type="hidden">
					<div class="form-group">
						<label class="col-sm-4 control-label">工作类型：</label>
						<div class="col-sm-8">
							<input type="text" name="w_type" class="form-control" required/>
						</div>
					</div>
					<!-- <div class="form-group">
						<label class="col-sm-4 control-label">过滤条件：</label>
						<div class="col-sm-8">
						<select class="form-control" name="c_flag">
						    <option value="无">无</option> 
								<option value="部门">部门</option> 
								<option value="个人">个人</option> 
							</select>
							
						</div>
					</div> -->
					<div class="form-group">
						<label class="col-sm-4 control-label">推送人：</label>
						<div class="col-sm-8">
						<input id="c01" name="c01" type="hidden">
						<div class="input-group">
							<input type="text" name="c011" id="c011" class="form-control" autocomplete="off" required/>
					 	   <span class="input-group-addon" ><i class="fa fa-times" style="color:red" onclick="clearMember()"  ></i></span>
						   <span class="input-group-addon" ><i class="fa fa-search" onclick="selectMember()"  ></i></span>
					</div>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-4 control-label">处理程序链接：</label>
						<div class="col-sm-8">
							<input type="text" name="c02" class="form-control" required/>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-4 control-label">推送字符头：</label>
						<div class="col-sm-8">
							<input type="text" name="c03" class="form-control" required/>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-4 control-label">推送SQL语句：</label>
						<div class="col-sm-8">
							<!-- <input type="text" name="c05" class="form-control" required/>  -->
							<textarea name="c05"  rows="3" maxlength="200" class="form-control"></textarea>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-4 control-label">推送到微信：</label>
						<div class="col-sm-8">
							<select class="form-control" name="c04">
								<option value="是">是</option> 
								<option value="否">否</option> 
							</select>
						</div>
					</div>
				</form>
	      </div>
	      <div class="modal-footer">
		        <button type="button" class="btn btn-default" data-dismiss="modal">关闭窗口</button>
		        <button type="button" class="btn btn-primary" onclick="saveContent()">保存</button>
		      </div>
	    </div><!-- /.modal-content -->
	  </div><!-- /.modal-dialog -->
</div>
	
	<script type="text/javascript">
		var prefix = "#(ctx)/w_ts_type";

		$(function() {
		    queryList();
		});

		function queryList() {
		    var options = {
		        url: prefix + "/list",
		        removeUrl: prefix + "/remove",
		        sortName: "w_type",
		        sortOrder: "w_type",
				uniqueId: "id",
		        modalName: "新增推送工作类型",
		        columns: [{
		            checkbox: true
		        },
		        {
		            field: 'w_type',
		            title: '工作类型',
		            width:'100px'
		        },/* ,
		        {
		            field: 'c_flag',
		            title: '推送人模式',
		            width:'50px'
		        }, */
		        {
		            field: 'c011',
		            title: '推送人',
		            width:'150px'
		        },
		        {
		            field: 'c02',
		            title: '处理程序链接',
		            width:'150px'
		        },
		        {
		            field: 'c03',
		            title: '推送字符头',
		            width:'100px'
		        },
		        {
		            field: 'c05',
		            title: '推送SQL语句',
		            width:'200px'
		        },
		        {
		            field: 'c04',
		            title: '是否推送到微信',
		            width:'80px'
		        },
		       /*  {
		        	field:'opt',
		            title: '操作',
		            width:'100px',
		            align: 'center',
		            formatter: function(value, row, index) {
		                var actions = [];
		                actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="openList(\''+row.id+'\')"><i class="fa fa-file"></i>材料信息</a> ');
		                return actions.join('');
		            }
		        } */
		        ],
		        onLoadSuccess:function(){
		        	
		        }
		    };
		    $.table.init(options);

		    $("#bootstrap-table").colResizable({
				liveDrag:true, 
				gripInnerHtml:"<div class='grip'></div>", 
				draggingClass:"dragging", 
	            resizeMode:'overflow'
	        });
		}
		
		//添加子节点
		function doAdd()
		{
	    	$('#form-config-add')[0].reset();
	    	$("#add_modal").modal({backdrop:true,keyboard:true});
			$('#id').val("");
		}
		//编辑节点
		function doEdit()
		{
			var row = $("#bootstrap-table").bootstrapTable('getSelections')[0];
        	if ($.common.isEmpty(row)) {
    			$.modal.alertWarning("请至少选择一条记录");
    			return;
    		}
        	var id=row.id;
	    	$('#form-config-add')[0].reset();
	    	$("#add_modal").modal({backdrop:true,keyboard:true});
			$('#id').val(id);
			$('#form-config-add').loadForm(prefix+'/getData?id='+id);
		}
		
		//保存
	    function saveContent() {
	    	var data=$('#form-config-add').serialize();
	    	var config = {
		   	        url: prefix+"/save",
		   	     	type: "post",
			        dataType: "json",
		   	        data: data,
		   	        beforeSend: function () {
			        	$.modal.loading("正在处理中，请稍后...");
			        	$.modal.disable();
		   	        },
		   	        success: function(result) {
		   	        	if(result.code==0)
		       			{
		   	        		refresh();
		                }
		   	        	else {
		                  $.modal.alertError(result.msg);
		                }
		   	        	$.modal.closeLoading();
		   	        	$("#add_modal").modal('hide');
		   	        }
		   	    };
		   	    $.ajax(config);
	    }
		
	    function refresh()
	    {
	    	$.table.search();
	    }
	    
	    function selectMember()
        {
	    	var lx='gzlx';
        	var url="#(ctx)/gemba_user_select?kind="+lx;
        	$.modal.open('选择推送人员',url,550,400);
        }
        
        function setUser(cuser,cname)
        {
        	$('#c011').val($('#c011').val()+cname);
        
			$("#c01").val($('#c01').val()+cuser);
		}
        function clearMember()
        {
			$('#c011').val("");
			$("#c01").val("");
        }
	    
	</script>
</body>

#end